package com.example.mapper;

import com.example.dto.StudentCountDto;
import com.example.dto.StudentDegreeDataDto;
import com.example.params.StudentQueryParam;
import com.example.pojo.Student;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Service;

import java.util.List;

@Mapper
public interface StudentMapper {
    //查询班级下是否有关联的学生
    @Select("select * from student where clazz_id=#{clazzId}")
    List<Student> findRelatedStudentByClass(Integer clazzId);

    List<Student> queryAllStudent(StudentQueryParam studentQueryParam);
    @Insert("insert into student(name,no,gender,phone,id_card,is_college,address,degree,graduation_date,clazz_id,create_time,update_time) values(#{name},#{no},#{gender},#{phone},#{idCard},#{isCollege},#{address},#{degree},#{graduationDate},#{clazzId},#{createTime},#{updateTime})")
    int addStudent(Student student);
    @Select("select * from student where id=#{id}")
    Student getStudentById(Integer id);

    int updateStudent(Student student);

    int deleteStudentByIds(@Param("ids") List<Integer> ids);
    @Update("update student set violation_score=violation_score+#{score} , violation_count = violation_count +1 where id=#{id}")
    int handleViolation(@Param("id") Integer id, @Param("score") Integer score);

    List<StudentCountDto> getStudentCount();

    List<StudentDegreeDataDto> getStudentDegreeData();
}